package com.cakin.javademo;

/**
 * @ClassName: com.cakin.javademo.Puppy
 * @Description: 小狗实体类
 * @Date: 2020/6/11
 * @Author: cakin
 */
// 一个源文件中可以有多个非public的类定义
class cat{

}
class dog{

}
// 源文件的名称应该和public类的类名保持一致。
public class Puppy {
    // 实例变量
    int puppyAge;

    String name;

    // 构造函数
    public Puppy(int puppyAge, String name) {
        this.puppyAge = puppyAge;
        this.name = name;
    }

    public int getPuppyAge() {
        return puppyAge;
    }

    public void setPuppyAge(int puppyAge) {
        this.puppyAge = puppyAge;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static void main(String[] args) {
        /* 创建对象 */
        Puppy myPuppy = new Puppy(1, "xiaobai");
        /* 通过方法来设定age */
        myPuppy.setPuppyAge(2);
        /* 调用另一个方法获取age */
        myPuppy.getPuppyAge();
        myPuppy.setName("xiaohei");
        /* 你也可以像下面这样访问成员变量 */
        System.out.println("age :" + myPuppy.puppyAge + " name:" + myPuppy.getName());
    }
}
